home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 4 code / Poly. in Code Resources / Virtual WDEF / WDEF_Tester.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-24  |  2.2 KB  |  114 lines  |  [TEXT/KAHL]

  1. /*
  2.     WDEF_Tester.c
  3.     
  4.     Code to test WDEF's.
  5.     
  6.     by Patrick Beard.
  7.  */
  8.  
  9. #include <EventMgr.h>
  10. #include <DialogMgr.h>
  11. #include <TextEdit.h>
  12.  
  13. #ifndef nil
  14. #define nil 0L
  15. #endif
  16.  
  17. main()
  18. {
  19.     Boolean quit = false;
  20.     WindowPtr w;
  21.     long i;
  22.     Str255 name;
  23.     
  24.     init();
  25.     
  26.     for(i = 1; i < 5; i++) {
  27.         w = GetNewWindow(128, nil, -1L);
  28.         NumToString(i, name);
  29.         SetWTitle(w, name);
  30.     }
  31.     
  32.     while(!quit) {
  33.         EventRecord evt;
  34.         SystemTask();
  35.         if(GetNextEvent(everyEvent, &evt)) {
  36.             GrafPtr oldPort;
  37.             GetPort(&oldPort);
  38.             
  39.             switch(evt.what) {
  40.             case updateEvt:
  41.                 {
  42.                     WindowPtr w = (WindowPtr)evt.message;
  43.                     SetPort(w);
  44.                     BeginUpdate(w);
  45.                     EraseRect(&w->portRect);
  46.                     GetWTitle(w, name);
  47.                     MoveTo(10, 20);
  48.                     DrawString("\pWindow # "); DrawString(name);
  49.                     EndUpdate(w);
  50.                 } break;
  51.             case mouseDown:
  52.                 {
  53.                     WindowPtr w = 0;
  54.                     short where;
  55.                     Point sizePt;
  56.                     where = FindWindow(evt.where, &w);
  57.                     if(w) {
  58.                         if(!(evt.modifiers & cmdKey) && w != FrontWindow())
  59.                             SelectWindow(w);
  60.                         switch(where) {
  61.                         case inDrag:
  62.                             DragWindow(w, evt.where, &screenBits.bounds);
  63.                             break;
  64.                         case inGrow: {
  65.                                 Rect bBox = { 50, 50, 32767, 32767 };
  66.                                 if(*(long*)&sizePt = GrowWindow(w, evt.where, &bBox))
  67.                                     SizeWindow(w, sizePt.h, sizePt.v, true);
  68.                             }
  69.                             break;
  70.                         case inZoomIn:
  71.                         case inZoomOut:
  72.                             SetPort(w);
  73.                             EraseRect(&w->portRect);
  74.                             ZoomWindow(w, where, true);
  75.                             break;
  76.                         case inGoAway:
  77.                             if(TrackGoAway(w, where))
  78.                                 HideWindow(w);
  79.                             break;
  80.                         }
  81.                     }
  82.                 } break;
  83.             case keyDown:
  84.                 quit = true;
  85.                 break;
  86.             }
  87.             SetPort(oldPort);
  88.         }
  89.     }
  90. }
  91.  
  92. init()
  93. {
  94.     EventRecord event;
  95.     
  96.     /* Standard Initialization Sequence */
  97.     InitGraf(&thePort);    /* set up quickdraw */
  98.     InitFonts();            /* Set up fonts        */
  99.     FlushEvents(everyEvent,0);    /* empty the event queue */
  100.     InitWindows();            /* Set up window manager */
  101.     InitMenus();            /* Set up menus */
  102.     TEInit();                /* Needed for Dialogs */
  103.     InitDialogs(nil);/* default could be nil */
  104.     
  105.     /* ask for the maximum application zone. */
  106.     MaxApplZone();
  107.     
  108.     /* get a plain cursor. */
  109.     InitCursor();
  110.     
  111.     /* for multifinder, bring us to the front. */
  112.     GetNextEvent(everyEvent, &event);
  113.     GetNextEvent(everyEvent, &event);
  114. }